Skip to main content

Global Variables

Introduction

This document provides a detailed overview of the "Global Variable" feature in the data menu of a Digisquares application. Global variables are essential for storing values that can be accessed and modified throughout the entire application, regardless of the page or workflow.

Definition

Global variables are variables that can be accessed globally across different pages and workflows within an application. They are used to store data that needs to be shared or maintained throughout the application's lifecycle.

Usage

  • User Session Management: Store user session information such as user ID, authentication tokens, or preferences.
  • Global States: Maintain global application states, such as theme settings, language preferences, or feature toggles.
  • Data Sharing: Share data between different parts of the application without the need for complex data passing mechanisms.

Creating and Managing Global Variables

To create and manage global variables in a Digisquares application, follow these steps:

Step-by-Step Guide

1. Accessing the Global Variable Menu

  1. Navigate to the data menu in your Digisquares application.
  2. Select the "Global Variable" option from the list. This will open the global variable configuration interface.

2. Defining a New Global Variable

  1. GlobalName: Enter a unique name for the global variable.
  2. Select Flow: Choose between "Workflow" or "PageFlow" to determine the scope of the variable.
  3. Name: Enter the name of the variable.
  4. Type: Select the data type for the variable (e.g., string, number, boolean).
  5. Value: Enter the initial value of the variable. Click the "+" button to add the value.

Example:

{
"globalName": "UserSession",
"flow": "Workflow",
"variables": [
{
"name": "UserID",
"type": "string",
"value": "12345"
}
]
}

3. Saving the Global Variable

After defining the global name, flow, name, type, and value, click the "Save" button to save the global variable configuration. The new global variable is now available for use throughout the application.

Example Usage

User Session Management

To use a global variable for user session management:

  • Define a global variable to store user session information.
  • Access and update the global variable as needed throughout the application.
{
"globalName": "UserSession",
"flow": "Workflow",
"variables": [
{
"name": "AuthToken",
"type": "string",
"value": "abcd1234"
},
{
"name": "UserID",
"type": "string",
"value": "12345"
}
]
}

Global States

To use a global variable for maintaining global states:

  1. Define a global variable to store the state information.
  2. Access and update the global variable to manage the state across different parts of the application.
{
"globalName": "AppSettings",
"flow": "Workflow",
"variables": [
{
"name": "Theme",
"type": "string",
"value": "dark"
},
{
"name": "Language",
"type": "string",
"value": "en"
}
]
}

Managing Existing Global Variables

To edit or delete an existing global variable:

  • Navigate to the global variable menu.
  • Select the global variable you wish to manage.
  • Update the values, type, or name as needed, or delete the global variable if it is no longer required.

Best Practices for Using Global Variables

  • Consistent Naming: Use consistent and descriptive names for global variables to improve readability and maintainability.
  • Minimal Scope: Limit the use of global variables to only necessary data to avoid unnecessary complexity and potential conflicts.
  • Security: Avoid storing sensitive information in global variables without proper encryption or security measures.
  • Centralized Management: Manage global variables centrally to easily update and maintain shared data across the application.

Conclusion

Global variables are a powerful feature in a Digisquares application, allowing for the storage and sharing of data across different parts of the application. By understanding how to define, use, and manage global variables, you can ensure efficient data handling and improve the overall functionality of your application.